<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>json格式返回值</title>
</head>
<body>
	<h1>json 格式返回值</h1>
	<ul>
		<li></li>
		<li></li>
		<li></li>
	</ul>
</body>
<script type="text/javascript" src='jquery-3.1.1.js'></script>
<script type="text/javascript">
	$('ul').click(function(){
		//如果PHP里的数组是关联数组,则json处理时,msg的返回值是对象
		//如果PHP里的数组是索引数组,则json处理时,msg的返回值是数组
		//$.get('24.php',function(msg){console.log(msg)},'json');
		$.get('24.php',function(msg){
			//console.log(msg);
			// console.log(JSON.parse(msg));
			//面向过程的方式
			for(var i=0; i<msg.length; i++){
				$('li')[i].innerHTML = msg[i];
			}
			//面向函数式的编程
			var i = 0;
			$('li').each(function(){
				this.innerHTML = msg[i++];
			});
		},'json');
	});
</script>
</html>